********************************************************************************************************************************
***   Replication file for:                                                                                                  ***
***   Berbee, P., Braun, S. T. and Franke, R. (2024). Reversing Fortunes of German Regions, 1926-2019. JoEG				     ***
***   							                                                                                             ***
***   SCRIPT: 	_x2d_preparation_census_1939.do																				 ***	
***   PURPOSE: 	Reads in and prepares data from the 1939 occupation and population census								 	 ***
********************************************************************************************************************************

* Preamble (unnecessary when executing run.do)
run "$reversing/scripts/programs/_config.do"

************
* Code begins
************

*** Import data

*** Occupation census 

import excel "$reversing/data/Berufszaehlung_1939.xlsx", sheet("Data") first clear

destring T_ID, replace
rename T_ID labor_market_id

gen empshare_agr_1939 = to_emp_wa1_to / to_emp_to
label var empshare_agr_1939 "Employment share in agriculture, 1939"
gen empshare_ind_1939 = to_emp_wa24_to / to_emp_to
label var empshare_ind_1939 "Employment share in industry, 1939"
gen empshare_serv_1939 = (to_emp_wa5_to + to_emp_wa6_to + to_emp_wa7_to) / to_emp_to
label var empshare_serv_1939 "Employment share in services, 1939"

*** Save data

keep labor_market_id empshare_agr_1939 empshare_ind_1939 empshare_serv_1939

sort labor_market_id

save "$reversing/processed/intermediate/occ_census1939.dta",replace


*** EOF



